/**
 * Created by duixintong on 2018/9/26.
 */
exports.install = function (Vue, options) {
    Vue.prototype.isEmpty = function (value) {
    let type
    if (value == null) {
      return true
    }
    type = Object.prototype.toString.call(value).slice(8, -1)
    switch (type) {
      case 'String':
        return value.length === 0
      case 'Array':
        return !value.length
      case 'Object':
        return Object.keys(value).length === 0 && value.constructor === Object
      default:
        return false
    }
  },
      Vue.prototype.dateFormat =  function (value, fmt) {
        if(!value) return
        let getDate = new Date(value);
        let o = {
          'M+': getDate.getMonth() + 1,
          'd+': getDate.getDate(),
          'h+': getDate.getHours(),
          'm+': getDate.getMinutes(),
          's+': getDate.getSeconds(),
          'q+': Math.floor((getDate.getMonth() + 3) / 3),
          'S': getDate.getMilliseconds()
        };
        if (/(y+)/.test(fmt)) {
          fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length))
        }
        for (let k in o) {
          if (new RegExp('(' + k + ')').test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
          }
        }
        return fmt;
      }
}
